<template>
  <div class="use-charts">
    <div class="header">
      <p class="subject">库存使用情况</p>
    </div>

    <!-- 图表 -->
    <chart :chartData="chartData" />
  </div>
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import Chart, { IPieChartData } from './charts/index.vue'
import { getStorageUseInformation } from '@/module-base/api/dashboard'

@Component({
  name: 'UseCharts',
  components: {
    Chart
  }
})
export default class extends Vue {
  private chartData = {} as IPieChartData

  created() {
    this.initData()
  }

  private async initData() {
    const { data } = await getStorageUseInformation()
    const series = data
    const legend = [] as string[]
    for (const item of series) {
      legend.push(item)
    }
    this.chartData = {
      series, legend
    }
  }
}
</script>

<style lang="scss" scoped>
@import 'index';
</style>
